import os
import copy

BIN_DIR = os.environ['BIN_DIR'];
LIB_DIR = os.environ['LIB_DIR'];
LCD_DEICES = os.environ['LCD_DEICES']

env = DefaultEnvironment().Clone()
SOURCES = [
  'input_thread/mouse_thread.c', 
  'input_thread/input_thread.c', 
  'input_thread/input_dispatcher.c', 
  'lcd_linux/lcd_linux_fb.c', 
  'lcd_linux/lcd_linux_drm.c', 
  'lcd_linux/lcd_linux_egl.c', 
  'lcd_linux/lcd_mem_others.c' ,
  'main_loop_linux.c' ]

if os.environ['TSLIB_LIB_DIR']:
  SOURCES = ['input_thread/tslib_thread.c'] + SOURCES;

if LCD_DEICES =='egl_for_fsl' :
  SOURCES = Glob('egl_devices/fsl/*.c') + SOURCES;
elif LCD_DEICES =='egl_for_x11' :
  SOURCES = Glob('egl_devices/x11/*.c') + SOURCES;
elif LCD_DEICES =='egl_for_rpi' :
  SOURCES = Glob('egl_devices/rpi/*.c') + SOURCES;

env.Library(os.path.join(LIB_DIR, 'awtk_linux_fb'), SOURCES)

env['LIBS'] = ['awtk_linux_fb'] + env['LIBS']

env.Program(os.path.join(BIN_DIR, 'mouse_test'), ["test/mouse_thread_test.c"])
env.Program(os.path.join(BIN_DIR, 'input_test'), ["test/input_thread_test.c"])
env.Program(os.path.join(BIN_DIR, 'fb_test'), ["test/fb_test.c"])

if os.environ['TSLIB_LIB_DIR']:
  env.Program(os.path.join(BIN_DIR, 'tslib_test'), ["test/tslib_thread_test.c"])
